package com.weirdor.wxchat.www.web;

import com.weirdor.wxchat.support.exception.PassionException;
import com.weirdor.wxchat.support.utils.R;
import com.weirdor.wxchat.support.utils.UuidUtils;
import com.weirdor.wxchat.support.utils.qiNiuUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by weirdor on 2017/11/7.
 */
@RestController
@RequestMapping("sys/oss")
public class UploadPictureController {

    @RequestMapping("/uploadPicture")
    public R uploads(@RequestParam("file") MultipartFile file)throws Exception {
        if (file.isEmpty()) {
            throw new PassionException("上传文件不能为空");
        }
        return R.ok().put("url",  qiNiuUtils.simpleupload(file.getBytes(), UuidUtils.getUUID()+file.getOriginalFilename(),"asstes"));
    }
}
